//
//  ApplicationManager.m
//  DaYing
//
//  Created by DaYing  on 2023.
//  Copyright © 2023 DaYing . All rights reserved.
//

#import "ApplicationManager.h"

#import "DYFirstBootViewController.h"
#import "DYHomePageViewController.h"

@interface ApplicationManager ()

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UINavigationController *firstBootNavigationController;//首次引导页
@property (strong, nonatomic) UINavigationController *homePageNavigationController;

@end

@implementation ApplicationManager

+ (instancetype)shareInstance {
    static ApplicationManager *_manager = nil;
    static dispatch_once_t oncePredicate;
    dispatch_once(&oncePredicate, ^{
        _manager = [[self alloc] init];
    });
    return _manager;
}

- (void)setupWindow:(UIWindow *)window {
    _window = window;
    if (kUserManager.userManager.step == 0) {
        //首次引导
        window.rootViewController = self.firstBootNavigationController;;
    } else {
        window.rootViewController = self.homePageNavigationController;
    }
                
    [window makeKeyAndVisible];
}

#pragma mark - 懒加载

//首次引导页
- (UINavigationController *)firstBootNavigationController {
    if (!_firstBootNavigationController) {
        DYFirstBootViewController *vc = [DYFirstBootViewController new];
        _firstBootNavigationController = [[UINavigationController alloc] initWithRootViewController:vc];
        _firstBootNavigationController.navigationBarHidden = YES;
    }
    return _firstBootNavigationController;
}

- (UINavigationController *)homePageNavigationController {
    if (!_homePageNavigationController) {
        DYHomePageViewController *vc = [DYHomePageViewController new];
        _homePageNavigationController = [[UINavigationController alloc] initWithRootViewController:vc];
        _homePageNavigationController.navigationBarHidden = YES;
    }
    return _homePageNavigationController;
}

@end
